<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<script>
    function max(arr){
        if(!Array.isArray(arr))return;
        var max=-Infinity,len=arr.length;
        while(len--){
            if(arr[len]>max){
                max=arr[len];
            }
        }
        return max;
    }

    console.log(max('abc'));

    console.log(max([10,1,2,3,20]));
</script>
</body>
</html>